import requests
# User-Agent: 理解为浏览器的衣服
url = "http://www.jianshu.com"
# 为爬虫穿上浏览器的衣服(设置 User-Agent)
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36"}
resp = requests.get(url, headers=headers)
print(resp.text)